package com.redepronik.negosys.rrhh.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * The persistent class for the empleado database table.
 * 
 */
@Entity
@Table(schema = "rrhh", name = "empleado")
@NamedQuery(name = "Empleado.findAll", query = "SELECT e FROM Empleado e")
public class Empleado implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(allocationSize = 1, name = "EMPLEADO_EMPLEADOID_GENERATOR", sequenceName = "RRHH.EMPLEADO_EMPLEADOID_SEQ")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EMPLEADO_EMPLEADOID_GENERATOR")
	@Column(unique = true, nullable = false)
	private Integer empleadoid;

	@Column(nullable = false)
	private Boolean activo;

	@Column(length = 10)
	private String folio;

	// bi-directional many-to-one association to Persona
	@OneToOne
	@JoinColumn(name = "personaid", nullable = false)
	private Persona persona;

	// bi-directional many-to-one association to Empleadocargo
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "empleado")
	private List<Empleadocargo> empleadocargos;

	public Empleado() {
	}

	public Empleadocargo addEmpleadocargo(Empleadocargo empleadocargo) {
		getEmpleadocargos().add(empleadocargo);
		empleadocargo.setEmpleado(this);

		return empleadocargo;
	}

	public Boolean getActivo() {
		return this.activo;
	}

	public List<Empleadocargo> getEmpleadocargos() {
		return this.empleadocargos;
	}

	public Integer getEmpleadoid() {
		return this.empleadoid;
	}

	public String getFolio() {
		return this.folio;
	}

	public Persona getPersona() {
		return this.persona;
	}

	public Empleadocargo removeEmpleadocargo(Empleadocargo empleadocargo) {
		getEmpleadocargos().remove(empleadocargo);
		empleadocargo.setEmpleado(null);

		return empleadocargo;
	}

	public void setActivo(Boolean activo) {
		this.activo = activo;
	}

	public void setEmpleadocargos(List<Empleadocargo> empleadocargos) {
		this.empleadocargos = empleadocargos;
	}

	public void setEmpleadoid(Integer empleadoid) {
		this.empleadoid = empleadoid;
	}

	public void setFolio(String folio) {
		this.folio = folio;
	}

	public void setPersona(Persona persona) {
		this.persona = persona;
	}

}